﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Popup_Cost1.aspx.cs" Inherits="Popup_Popup_Cost1" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <link href="../CustomCss.css" rel="stylesheet" type="text/css" />
    <link href="../resources/css/examples.css" rel="stylesheet" type="text/css" />
    <ext:XScript ID="XScript1" runat="server">
    <script type="text/javascript">       
       
       var CreateRow = function(){
            parent.SelectAddMat(document.getElementById("hdRowValue").value, "1");
            parent.Ext.getCmp('Window1').hide();
       }
       
       //콤보박스 (거래처- 주요자재, 장비연황) --  공용으로 처리
       var cbxRenderEqp = function (value, metadata, record) {
           var r =  StrBiz.getById(value);
                if (Ext.isEmpty(r)) {
                    return value;
                }
                return r.data.CODE2_NM;
        }
        

            var addEmployee = function () {
            
                var grid = #{GrdPnlUp};
                var index =  #{Store1}.getCount();
                grid.stopEditing();
                grid.insertRecord(index, {
                    CODE2 : document.getElementById("cbxGubun").value
                    
                });
                grid.getView().focusRow(index);
                grid.getView().focusCell(index,4);
                grid.selModel.selectRow(index);
                grid.startEditing(index,4);
            }
        
 
            var removeEmployee = function () {
                var grid = #{GrdPnlUp};
                grid.stopEditing();
                
                var s = grid.getSelectionModel().getSelections();
                
                for (var i = 0, r; r = s[i]; i++) {
                    #{Store1}.remove(r);
                }
                
            }
            
            
            
            var addEmployee2 = function () {
            
                var grid = #{GrdPnlDown};
                var index =  #{Store2}.getCount();
                grid.stopEditing();
                grid.insertRecord(index, {
                    CODE2 : document.getElementById("cbxGubun").value
                    
                });
                grid.getView().focusRow(index);
                grid.getView().focusCell(index,4);
                grid.selModel.selectRow(index);
                grid.startEditing(index,4);
            }
        
 
            var removeEmployee2 = function () {
                var grid = #{GrdPnlDown};
                grid.stopEditing();
                
                var s = grid.getSelectionModel().getSelections();
                
                for (var i = 0, r; r = s[i]; i++) {
                    #{Store2}.remove(r);
                }
                
            }
       
       
    </script>
    </ext:XScript>
    <title>제목 없음</title>
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <ext:Store ID="StrBiz" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="CODE2">
                <Fields>
                    <ext:RecordField Name="CODE2" />
                    <ext:RecordField Name="CODE2_NM" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Viewport ID="Viewport1" runat="server" StyleSpec="background-color: transparent;">
        <Items>
            <ext:BorderLayout ID="BorderLayout1" runat="server">
                <North>
                    <ext:Panel ID="Panel3" runat="server" Title="" StyleSpec="height:60px;" >
                        <Content>
                            <table style="width:100%;">
                                <tr>
                                    <td>
                                        <table>
                                            <tr>
                                                <td>
                                                    <ext:Button ID="btnAdd1" runat="server" Text="추가" Icon="Add">
                                                        <Listeners>
                                                            <Click Fn="addEmployee" />
                                                        </Listeners>
                                                    </ext:Button>
                                                </td>
                                                <td>
                                                    <ext:Button ID="btnSave1" runat="server" Text="저장" Icon="Accept">
                                                        <Listeners>
                                                            <Click Handler="#{GrdPnlUp}.save();" />
                                                        </Listeners>
                                                    </ext:Button>
                                                </td>
                                                <td>
                                                    <ext:Button ID="btnDel1" runat="server" Text="삭제" Icon="Delete">
                                                        <Listeners>
                                                            <Click Fn="removeEmployee" />
                                                        </Listeners>
                                                    </ext:Button>
                                                </td>
                                                <td style="width:44%;">
                                                </td>
                                                <td>
                                                    <ext:Button ID="btnAdd2" runat="server" Text="추가" Icon="Add">
                                                        <Listeners>
                                                            <Click Fn="addEmployee2" />
                                                        </Listeners>
                                                    </ext:Button>
                                                </td>
                                                <td>
                                                    <ext:Button ID="btnSave2" runat="server" Text="저장" Icon="Accept">
                                                        <Listeners>
                                                            <Click Handler="#{GrdPnlDown}.save();" />
                                                        </Listeners>
                                                    </ext:Button>
                                                </td>
                                                <td>
                                                    <ext:Button ID="btnDel2" runat="server" Text="삭제" Icon="Delete">
                                                        <Listeners>
                                                            <Click Fn="removeEmployee2" />
                                                        </Listeners>
                                                    </ext:Button>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <table>
                                            <tr>
                                                <td>
                                                   비목분류 
                                                </td>
                                                <td>
                                                    구분 : 
                                                </td>
                                                <td>
                                                    <ext:ComboBox ID="cbxGubun" runat="server">
                                                        <DirectEvents>
                                                            <Select OnEvent="cbxGubun_Change">
                                                            </Select>
                                                        </DirectEvents>
                                                    </ext:ComboBox>
                                                </td>
                                                <td style="width:380px;">
                                                    품명분류
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </Content>
                    </ext:Panel>
                </North>
                <West Collapsible="true" Split="true" MinWidth="420" MaxWidth="420" MarginsSummary="5 0 5 5" CMarginsSummary="31 5 5 5">
                    <ext:Panel runat="server" Title="" ID="pnlWest" AutoScroll="true" StyleSpec="width:400px;">
                        <Items>
                            <ext:GridPanel ID="GrdPnlUp" runat="server" AutoScroll="true" Cls="my-grid" Height="350">
                                <Store>
                                    <ext:Store ID="Store1" runat="server" OnBeforeStoreChanged="Store_BeforeChanged">
                                        <Reader>
                                            <ext:JsonReader>
                                                <Fields>
                                                    <ext:RecordField Name="NUDE" />
                                                    <ext:RecordField Name="KIND" />
                                                    <ext:RecordField Name="CODE" />
                                                    <ext:RecordField Name="NAME" />
                                                    <ext:RecordField Name="CODE2" />
                                                    <ext:RecordField Name="CODE2_NM" />
                                                </Fields>
                                            </ext:JsonReader>
                                        </Reader>
                                        <Listeners>
                                            <LoadException Handler="var e = e || {메시지: response.responseText}; alert('로드하지 못했습니다.: ' + e.message);" />
                                        </Listeners>
                                    </ext:Store>
                                </Store>
                                <View>
                                    <ext:GridView ID="GridView1" runat="server"/>
                                </View>
                                <ColumnModel ID="ColumnModel2" runat="server">
                                    <Columns>
                                        <ext:Column ColumnID="NUDE" Header="NUDE" Width="60" DataIndex="NUDE" Hidden="true" />
                                        <ext:Column ColumnID="CODE" Header="CODE" Width="70" DataIndex="CODE" Hidden="true" />
                                        <ext:Column ColumnID="KIND" Header="대분류" Width="120" DataIndex="KIND" />
                                        <ext:Column ColumnID="NAME" Header="분류명" Width="160" DataIndex="NAME">
                                            <Editor>
                                                <ext:TextField ID="tbxUpName" runat="server"></ext:TextField>
                                            </Editor>
                                        </ext:Column>
                                        <ext:Column ColumnID="CODE2" Header="구분" Width="100" DataIndex="CODE2">
                                            <Renderer Fn="cbxRenderEqp" />
                                            <Editor>
                                                <ext:ComboBox ID="cbxGubun1" runat="server" StoreID="StrBiz" DisplayField="CODE2_NM"
                                                                        ValueField="CODE2" />
                                            </Editor>
                                        </ext:Column>
                                    </Columns>
                                </ColumnModel>
                                <SelectionModel>
                                    <ext:RowSelectionModel ID="RowSelectionModel2" runat="server" SingleSelect="true">
                                        <DirectEvents>
                                            <RowSelect OnEvent="CreateParameter1">
                                                <ExtraParams>
                                                    <ext:Parameter Name="Values" Value="Ext.encode(#{GrdPnlUp}.getRowsValues({selectedOnly:true}))" Mode="Raw" />
                                                </ExtraParams>
                                            </RowSelect>
                                        </DirectEvents>
                                    </ext:RowSelectionModel>
                                </SelectionModel>
                            </ext:GridPanel>
                        </Items>
                    </ext:Panel>
                </West>
                <Center MarginsSummary="5 5 5 0">
                    <ext:FormPanel ID="formContent" runat="server" HideBorders="true">
                        <Items>
                            <ext:GridPanel ID="GrdPnlDown" runat="server" AutoScroll="true" Cls="my-grid" Height="350">
                                <Store>
                                    <ext:Store ID="Store2" runat="server" OnBeforeStoreChanged="Store_BeforeChanged">
                                        <Reader>
                                            <ext:JsonReader>
                                                <Fields>
                                                    <ext:RecordField Name="NUDE" />
                                                    <ext:RecordField Name="KIND" />
                                                    <ext:RecordField Name="CODE" />
                                                    <ext:RecordField Name="NAME" />
                                                    <ext:RecordField Name="CODE2" />
                                                </Fields>
                                            </ext:JsonReader>
                                        </Reader>
                                        <Listeners>
                                            <LoadException Handler="var e = e || {메시지: response.responseText}; alert('로드하지 못했습니다.: ' + e.message);" />
                                        </Listeners>
                                    </ext:Store>
                                </Store>
                                <View>
                                    <ext:GridView ID="GridView2" runat="server"/>
                                </View>
                                <ColumnModel ID="ColumnModel1" runat="server">
                                    <Columns>
                                        <ext:Column ColumnID="NUDE" Header="사업자번호" Width="60" DataIndex="NUDE" Hidden="true" />
                                        <ext:Column ColumnID="CODE2" Header="구분" Width="100" DataIndex="CODE2" Hidden="true" />
                                        <ext:Column ColumnID="KIND" Header="대분류" Width="120" DataIndex="KIND" Hidden="true" />
                                        <ext:Column ColumnID="CODE" Header="소분류" Width="70" DataIndex="CODE" />
                                        <ext:Column ColumnID="NAME" Header="분류명" Width="160" DataIndex="NAME">
                                            <Editor>
                                                <ext:TextField ID="tbxDown" runat="server"></ext:TextField>
                                            </Editor>
                                        </ext:Column>
                                    </Columns>
                                </ColumnModel>
                                <SelectionModel>
                                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
                                        <DirectEvents>
                                            <RowSelect OnEvent="CreateParameter2">
                                                <ExtraParams>
                                                    <ext:Parameter Name="Values" Value="Ext.encode(#{GrdPnlDown}.getRowsValues({selectedOnly:true}))" Mode="Raw" />
                                                </ExtraParams>
                                            </RowSelect>
                                        </DirectEvents>
                                    </ext:RowSelectionModel>
                                </SelectionModel>
                            </ext:GridPanel>
                        </Items>
                    </ext:FormPanel>
                </Center>
            </ext:BorderLayout>
        </Items>
    </ext:Viewport>
    <ext:Hidden ID="hdRowValue" runat="server" />
    <ext:Hidden ID="hdRowValue2" runat="server" />
    </form>
</body>
</html>
